//
// Created by user on 2022/3/9.
//
#include <vector>
#include <unordered_map>
using namespace std;
vector<int> twoSum(vector<int>& nums, int target) {
    vector<int> ans;
    unordered_map<int, int> map;

    for (int i = 0; i < nums.size(); ++i) {
        if(map.count(target-nums[i])){
            ans.push_back(map.at(target-nums[i]));
            ans.push_back(i);
            return ans;
        }
        map.insert(pair<int, int>(nums[i], i));
    }
    return ans;
}